package com.atguigu.spzx.user.controller;

import com.atguigu.spzx.model.entity.user.UserAddress;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import com.atguigu.spzx.user.service.UserAddressService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "地址接口管理")
@RestController
@RequestMapping(value="/api/user/userAddress/")
public class userAddress {

    @Autowired
    UserAddressService userAddressService;


    @Operation(summary = "获取用户地址")
    @GetMapping("auth/findUserAddressList")
    public Result findUserAddressList(){

        List<UserAddress> list = userAddressService.findUserAddressList();
        return Result.build(list, ResultCodeEnum.SUCCESS);

    }

    @Operation(summary = "新增地址")
    @PostMapping("auth/save")
    public Result addAddress(@RequestBody UserAddress userAddress){
        userAddressService.addAddress(userAddress);
        return Result.build(null, ResultCodeEnum.SUCCESS);

    }


}
